#define  _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
int main()
{
	int n = 0;
	scanf("%d ", &n);
	int i = 0, j = 0;
	char a[100];
	for (i = 0; i < n; i++)
	{
		int count = 0;
		gets(a);
		for (j = 0; a[j] != '\0'; j++)
		{
			if (a[j] >= '0' && a[j] <= '9')
			{
				count++;
			}
		}
		printf("%d", count);
		if (i != n - 1)
			printf("\n");
	}



	return 0;
}